package smedi.ismedi.mobile.bff.controller.personnel;

import com.smedi.ismedi.personnel.api.dto.request.PersonListQueryRequest;
import com.smedi.ismedi.personnel.api.dto.request.ScopeTopPermissionRequest;
import com.smedi.ismedi.personnel.api.dto.response.*;
import com.smedi.ismedi.personnel.api.dto.response.resp.PersonResp;
import com.smedi.ismedi.personnel.api.feign.RemotePersonCoreFeignApi;
import com.smedi.ismedi.web.starter.common.ResponseData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import smedi.ismedi.mobile.bff.controller.BaseController;

import java.util.List;

/**
 * 人员管理接口
 *
 * @author 徐林俊
 */
@Slf4j
@RestController
@Api(tags = {"人员管理接口"})
@RequestMapping("/mobilebff/v1/personnelCore")
@AllArgsConstructor
public class PersonCoreController extends BaseController {
    private final RemotePersonCoreFeignApi remotePersonCoreFeignApi;

    /**
     * 获取用户顶部的三级组织切换信息
     *
     * @return
     */
    @ApiOperation(httpMethod = "GET", value = "获取用户顶部的三级组织切换信息")
    @GetMapping(value = "/getScopeTopPermission")
    public ResponseData<ScopeTopPermissionResponse> getScopeTopPermission() {
        return remotePersonCoreFeignApi.getScopeTopPermission();
    }

    /**
     * 登录时获取数据权限，并绑定全量
     *
     * @return
     */
    @ApiOperation(httpMethod = "GET", value = "登录时获取数据权限，并绑定全量")
    @GetMapping(value = "/getLoginScopeInitializeDataAndSubmit")
    public ResponseData<ScopeTopPermissionResponse> getLoginScopeInitializeDataAndSubmit() {
        return remotePersonCoreFeignApi.getLoginScopeInitializeDataAndSubmit();
    }

    /**
     * 选中所选的三级组织权限
     *
     * @return
     */
    @ApiOperation(httpMethod = "POST", value = "选中所选的三级组织权限")
    @PostMapping(value = "/submitScopeTopPermission")
    public ResponseData<Boolean> postSubmitScopeTopPermission(@RequestBody ScopeTopPermissionRequest scopeTopPermissionRequest) {
        return remotePersonCoreFeignApi.postSubmitScopeTopPermission(scopeTopPermissionRequest);
    }

    /**
     * 获取人员详细信息
     *
     * @param personId
     * @return
     */
    @ApiOperation(httpMethod = "GET", value = "获取人员详细信息")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "personId", value = "人员id", dataType = "Long", dataTypeClass = Long.class)
    })
    @GetMapping(value = "/queryPersonDetailInfo")
    public ResponseData<PersonResponse> getQueryPersonDetailInfo(@RequestParam("personId") Long personId) {
        return remotePersonCoreFeignApi.getQueryPersonDetailInfo(personId);
    }

    /**
     * 获取项目中特定角色的人员
     *
     * @param projectId 项目id
     * @param roleIds   角色id列表
     * @return ResponseData<List < BidSectionResponse>>
     */
    @ApiOperation(httpMethod = "GET", value = "获取项目中特定角色的人员")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "projectId", value = "项目id", dataType = "Long", dataTypeClass = Long.class),
            @ApiImplicitParam(paramType = "query", name = "roleIds", value = "角色id列表", dataType = "List", dataTypeClass = List.class)
    })
    @GetMapping(value = "/getPersonInProjectWithRoleIds")
    public ResponseData<List<PersonResponse>> getPersonInProjectWithRoleIds(@RequestParam("projectId") Long projectId, @RequestParam("roleIds") List<Long> roleIds) {
        return remotePersonCoreFeignApi.getPersonInProjectWithRoleIds(projectId, roleIds);
    }

    /**
     * 获取项目中的人员
     *
     * @param projectId 项目id
     * @return ResponseData<List<PersonResponse>>
     */
    @ApiOperation(httpMethod = "GET", value = "获取项目中的人员")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "projectId", value = "项目id", dataType = "Long", dataTypeClass = Long.class),
    })
    @GetMapping(value = "/getPersonInProject")
    ResponseData<List<PersonResponse>> getPersonInProject(@RequestParam("projectId") Long projectId){

        return remotePersonCoreFeignApi.getPersonInProject(projectId);
    }

    /**
     * 获取用户顶部的三级组织切换信息
     *
     * @return ResponseData<ScopeTopPermissionInfoResponse<HrOrganizationInfoResponse, ProjectBasicInfoResponse>>
     */
    @ApiOperation(httpMethod = "GET", value = "获取用户顶部的三级组织切换信息")
    @GetMapping(value = "/getScopeTopPermissionInfo")
    public ResponseData<ScopeTopPermissionInfoResponse> getScopeTopPermissionInfo() {
        return remotePersonCoreFeignApi.getScopeTopPermissionInfo();
    }

    /**
     * 获取 人员 列表
     *
     * @param personListQueryRequest 人员列表查询
     * @return ResponseData<List < PersonResp>>
     */
    @ApiOperation(httpMethod = "POST", value = "查询 人员 列表")
    @PostMapping(value = "/getPersonList")
    ResponseData<List<PersonResp>> getPersonList(@Validated @RequestBody PersonListQueryRequest personListQueryRequest) {
        return remotePersonCoreFeignApi.getPersonList(personListQueryRequest);
    }
}
